/**
 * @author  guocailee
 */
import types from '../types.js'
let state = {
  base: {
    nickName: '',
    birthday: null,
    sex: null,
    headPortrait: '/static/img/avatar/avatar-default.jpg',
    address: ''
  },
  advanced: {
    idCard: null,
    region: null
  }
}

// mutations
const mutations = {
  [types.info.SET](state, info) {
    state = info
  },
  [types.info.UPDATE_BASEINFO](state, baseInfo) {
    state.base = baseInfo
  },
  [types.info.UPDATE_ADVANCED_INFO](state, advancedInfo) {
    state.advanced = advancedInfo
  },
  [types.info.UPDATE_AVATAR](state, headPortrait) {
    state.base.headPortrait = headPortrait
  },
  [types.info.UPDATE_GENDER](state, gender) {
    state.base.gender = gender
  },
  [types.info.UPDATE_BIRTHDAY](state, birthday) {
    state.base.birthday = birthday
  },
  [types.info.UPDATE_NICKNAME](state, nickName) {
    state.base.nickName = nickName
  },
  [types.info.UPDATE_ADDRESS](state, address) {
    state.base.address = address
  },
  [types.info.UPDATE_IDCARD](state, idCard) {
    state.advanced.idCard = idCard
  }
}

export default {
  state,
  mutations
}
